/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.erp.client;


import com.extjs.gxt.ui.client.widget.Info;
import com.google.gwt.i18n.client.DateTimeFormat;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONException;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;


/**
 *
 * @author Administrator
 */
public class test {

    public test() {
    }

    public List<Stock1> testarray(String jsonstring) {
        //List<RzlogStore> mystocks = new ArrayList<RzlogStore>();

        DateTimeFormat f = DateTimeFormat.getFormat("M/d h:mma");
        List<Stock1> stocks = new ArrayList<Stock1>();
        stocks.add(new Stock1("3m Co", 71.72, 0.02, 0.03, f.parse("4/2 12:00am"), "Manufacturing"));
        stocks.add(new Stock1("Alcoa Inc", 29.01, 0.42, 1.47, f.parse("4/1 12:00am"), "Manufacturing"));
        return stocks;
    }

   

    public String ttestarray(String jsonstring) {
        //List<RzlogStore> stocks = new ArrayList<RzlogStore>();
        String lllllls = "";
        String jsInputDate = "";
        String jsRecdata = "";
        String jsRecdate = "";
        String jsMangeDemo = "";
        double jsMangeNumerical = 0;
        double jsMangeId = 0;
        double jsDepid = 0;
        double jsRzid = 0;
        double jsEmpid = 0;
        try {
            // parse the response text into JSON
            JSONValue jsonValue = JSONParser.parse(jsonstring);
            JSONArray jsonArray = jsonValue.isArray();

            if (jsonArray != null) {
                JSONObject jsStock;


                for (int i = 0; i < jsonArray.size(); i++) {
                    //[{"depId":2,"empId":1,"inputDate":null,"mangeDemo":"","mangeId":0,"mangeNumerical":0,"recData":"","recDate":null,"rzId":0}]
                    jsStock = jsonArray.get(i).isObject();
                    if ((jsStock = jsonArray.get(i).isObject()) == null) {
                    } else {
                        //jsStock = jsonArray.get(i).isObject();
                        //---------int数据处理---------------
                        jsDepid = (int) jsStock.get("depId").isNumber().doubleValue();
                        jsEmpid = (int) jsStock.get("empId").isNumber().doubleValue();
                        jsRzid = (int) jsStock.get("rzId").isNumber().doubleValue();

                        if (jsStock.get("mangeId") == null) {
                            jsMangeId = 0;
                        } else {
                            jsEmpid = (int) jsStock.get("mangeId").isNumber().doubleValue();
                        }

                        if (jsStock.get("mangeNumerical") == null) {
                            jsMangeNumerical = 0;
                        } else {
                            jsMangeNumerical = (int) jsStock.get("mangeNumerical").isNumber().doubleValue();
                        }
                        //---------String数据处理---------------
                        jsInputDate = jsStock.get("inputDate").isString().toString();
                        jsRecdate = jsStock.get("recDate").isString().toString();
                        jsRecdata = jsStock.get("recData").isString().toString();

                        if (jsStock.get("mangeDemo") == null) {
                            jsMangeDemo = "";
                        } else {
                            jsMangeDemo = jsStock.get("mangeDemo").isString().toString();
                        }


                    }
                    lllllls = jsInputDate + jsRecdata + jsRecdate + jsMangeDemo + ";jsDepid--" + jsDepid + ";jsMangeId--" + jsMangeId + lllllls;


                }

            } else {
                throw new JSONException();
            }
        } catch (JSONException e) {
            lllllls = ("Could not parse JSON");
        }
        return lllllls;
    }
}
